﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VoicePhone.Common;

namespace VoicePhone.Utils
{

    public class VoiceKeyWordConfig : EntityClassXmlSerializer<VoiceKeyWordConfig>
    {
        public List<VoiceKeyWord> VoiceKeyWords { get; set; }

        public static VoiceKeyWordConfig Load()
        {
            VoiceKeyWordConfig voiceKeyWordConfig;
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config\\VoiceKeyWordConfig.xml");
            if (File.Exists(filePath))
            {
                string xmlStr = File.ReadAllText(filePath);
                voiceKeyWordConfig = ReadFromXML(xmlStr);
            }
            else
            {
                if (!Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config")))
                    Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config"));
                voiceKeyWordConfig = new VoiceKeyWordConfig();
            }
            if (voiceKeyWordConfig.VoiceKeyWords == null)
                voiceKeyWordConfig.VoiceKeyWords = new List<VoiceKeyWord>();

            return voiceKeyWordConfig;
        }
    }
    /// <summary>
    /// 关键词检索类-Add by lukun
    /// </summary>
    public class VoiceKeyWord 
    {
        /// <summary>
        /// 步骤枚举表
        /// </summary>
        public string StepItmEnum { get; set; }//步骤
        /// <summary>
        /// 操作
        /// </summary>
        public string Key1 { get; set; }
        /// <summary>
        /// 参数
        /// </summary>
        public string Key2 { get; set; }
        /// <summary>
        /// 参数
        /// </summary>
        public string Key3 { get; set; }
        /// <summary>
        /// 操作
        /// </summary>
        public string Key4 { get; set; }
        /// <summary>
        /// 操作
        /// </summary>
        public string Key5 { get; set; }
        /// <summary>
        /// 参数
        /// </summary>
        public string Para { get; set; }
        /// <summary>
        /// 匹配关键词的数量
        /// </summary>
        public int limitKey { get; set; }
    }
}
